import {getTimestamp,filterTimeHMS} from './time'
const Warn = class Warn{
    constructor(props){
        this.realName = props.realName;
        this.mobile = props.mobile;
        this.paidAmountStart = props.paidAmountStart;
        this.paidAmountEnd = props.paidAmountEnd;
        this.isCall = props.isCall;
        this.callNumStart = props.callNumStart;
        this.callNumEnd = props.callNumEnd;
        this.tellNumStart = props.tellNumStart;
        this.tellNumEnd = props.tellNumEnd;
        this.remindName = props.remindName;
        this.size = props.size;
        this.page = props.page;
        this.time = props.time;
        this.status = props.status;
    }
    getState(){
        let x = {}
        //姓名
        if(this.realName){
			x.realName = this.realName
        }
        //手机号
        if(this.mobile){
            if(!/^[1][3,4,5,6,7,8,9][0-9]{9}$/.test(this.mobile)){
                return {code:'0',message:'请输入正确的手机号'}
            }else{
                x.mobile = this.mobile
            }
        }
        //待还款金额
        if(this.paidAmountStart){
            if(!/^[0-9]*$/.test(this.paidAmountStart)){
                return {code:'0',message:'请输入正确的起始待还款金额'}
            }else{
                x.paidAmountStart = this.paidAmountStart
            }
        }
        if(this.paidAmountEnd){
            if(!/^[0-9]*$/.test(this.paidAmountEnd)){
                return {code:'0',message:'请输入正确的结束待还款金额'}
            }else{
                x.paidAmountEnd = this.paidAmountEnd
            }
        }
        if(this.paidAmountStart&&this.paidAmountEnd){
            if(Number(this.paidAmountStart)>=Number(this.paidAmountEnd)){
                return {code:'0',message:'起始金额不得大于结束金额'}
            }
        }
        //本人是否接通
        if(this.isCall){
            x.isCall = this.isCall
        }
        //提醒人数
        if(this.callNumStart){
            if(!/^[0-9]*$/.test(this.callNumStart)){
                return {code:'0',message:'请输入正确的起始提醒人数'}
            }else{
                x.callNumStart = this.callNumStart
            }
        }
        if(this.callNumEnd){
            if(!/^[0-9]*$/.test(this.callNumEnd)){
                return {code:'0',message:'请输入正确的结束提醒人数'}
            }else{
                x.callNumEnd = this.callNumEnd
            }
        }
        if(this.callNumStart&&this.callNumEnd){
            if(Number(this.callNumStart)>=Number(this.callNumEnd)){
                return {code:'0',message:'起始提醒人数不得大于结束提醒人数'}
            }
        }
        //愿意转告人数
        if(this.tellNumStart){
            if(!/^[0-9]*$/.test(this.tellNumStart)){
                return {code:'0',message:'请输入正确的起始转告人数'}
            }else{
                x.tellNumStart = this.tellNumStart
            }
        }
        if(this.tellNumEnd){
            if(!/^[0-9]*$/.test(this.tellNumEnd)){
                return {code:'0',message:'请输入正确的结束转告人数'}
            }else{
                x.tellNumEnd = this.tellNumEnd
            }
        }
        if(this.tellNumStart&&this.tellNumEnd){
            if(Number(this.tellNumStart)>=Number(this.tellNumEnd)){
                return {code:'0',message:'起始转告人数不得大于结束转告人数'}
            }
        }
        //提醒人
        if(this.remindName){
            x.remindName = this.remindName
        }

        // 提醒日期
        if(this.time){
            x.remindTimeStart = this.time ? getTimestamp(this.time[0]) : undefined;
            x.remindTimeEnd = this.time ? getTimestamp(this.time[1])+ 86399999 : undefined;
        }

        //提醒状态
        if(this.status){
            x.status = this.status
        }

        x.size = this.size
		x.page = this.page
		return x
    }
};

export  default Warn